$(function (){
    guid()
})

function gettime(){
    var date1 = new Date();
    var date = date1.getFullYear()+":"+(date1.getMonth()+1)+":"+date1.getDate()+"  "+date1.getHours()+":"+date1.getMinutes()+":"+date1.getSeconds();
    var date2 = date1.getFullYear()+"-"+(date1.getMonth()+1)+"-"+date1.getDate();
    $("#time2").val(date2)
    document.getElementById("time").innerHTML=date;
    window.setTimeout("gettime()",1000);
}
window.onload=gettime;

function  guid() {
    var r = Math.random().toString().replaceAll(".","").substr(1,6);
    $("#rukudan").val(r)
    $("#rukudan01").val(r)
}

function getHuZu() {
    var custName = $("#huzhu").val();
    if (custName != null ||custName!=""){
        $.ajax({
            type:"get",
            url:"rukuselectCusmer.do?custName="+custName,
            success:function (data) {
                $("#tablekehu").html("")
                $("#tablekehu").append("<tr style=\"background-color: #28a3e7\">\n" +
                    "<td>客户id</td>\n" +
                    "<td>客户名称</td>\n" +
                    "<td>客户手机</td>\n" +
                    "<td>客户电话</td>\n" +
                    "</tr>")
                for (var i=0;i<data.length;i++)
                {
                    $("#tablekehu").append("<tr  onmouseout='change(this)' onmouseover='over(this)' onclick='dianJi(\""+data[i].custId+"\",\""+data[i].custName+"\")'>" +
                        "<td>"+data[i].custId+"</td>" +
                        "<td>"+data[i].custName+"</td>" +
                        "<td>"+data[i].custIcChip+"</td>" +
                        "<td>"+data[i].custTel+"</td>" +
                        "</tr>")
                }

                // $("#tablekehu tr").click(function ()
                // {
                //     alert(this.cells.length)
                //     var add = this.cells[0].html()+"-"+this.cells[1].html();
                //     //2 输入框的内容是你点击的div的内容
                //     $("#huzhu").val(add);
                //     //1 让下方table内容清空
                //     $("#tablekehu").html("");
                // })
            }
        })
    }

}
function dianJi(custId,custName) {

    var add = custId+"-"+custName;
    // alert(add)
    //2 输入框的内容是你点击的div的内容
    $("#huzhu").val(add);
    //1 让下方table内容清空
    $("#tablekehu").html("");
}
function over(tr) {
    tr.style.backgroundColor="hsl(176,45%,43%)"
}
function change(tr) {
    tr.style.backgroundColor="white"
}

function showHuoZhu() {
    document.getElementById("HuoZhuDiv").hidden='';
    document.getElementById("HuoZhuDiv").display='block';
}


// onblur="hiddenHuoZhu()"   //加隐藏div的方法（弃用）
function hiddenHuoZhu() {
    var custName = $("#huzhu").val();
    if (custName == null ||custName==""){
    document.getElementById("HuoZhuDiv").hidden='hidden';
    document.getElementById("HuoZhuDiv").display='none';
    }
}